<!DOCTYPE html>
<html>
<head>
    <title data-culture="articleManagment">信息发布管理</title>

</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12 col-sm-12 col-xs-12">
            <div class="widget  no-padding">
                <div class="widget-header bg-themeprimary">
                    <i class="widget-icon typcn typcn-th-list"></i>
                    <span class="widget-caption" data-culture="articleList">信息发布列表</span>
                </div>
                <div class="widget-body">
                    <table id="grid-data">
                        <thead>
                        <tr>
                            <th style="text-align: center;" data-culture="articleName">标题</th>
                            <th style="text-align: center;" data-culture="articleName">类别</th>
                            <th style="text-align: center;" data-culture="articleName">发布部门</th>
                            <th style="text-align: center;" data-culture="articleName">发布人</th>
                            <th style="text-align: center;" data-culture="articleName">发布时间</th>
                            <th style="text-align: center;" data-culture="hits">点击</th>
                            <th style="text-align: center;" data-culture="articleName">状态</th>
                            <th style="width: 200px; text-align: center;" data-culture="operation">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="row-no-display">
                            <td style="text-align: center;"><a href="/views/cms/info/$id$.html" target="_blank">$title$</a></td>
                            <td style="text-align: center;">$categoryName$</td>
                            <td style="text-align: center;">$orgName$</td>
                            <td style="text-align: center;">$userName$</td>
                            <td style="text-align: center;" dateformat="YYYY-MM-DD HH:mm">$auditTime$</td>
                            <td style="text-align: center;">$hits$</td>
                            <td style="text-align: center;">$auditStatusName$</td>
                            <td class="text-left" style="text-align: center;">
                                <a rel='editArticle' class="btn btn-info btn-xs edit"><i
                                        class="fa fa-edit"></i><span data-culture="edit">编辑</span></a>
                                <a rel='preview' class="btn btn-success btn-xs edit"><i
                                        class="fa  fa-key"></i><span data-culture="preview">预览</span></a>
                                <a rel='deleteArticle' class="btn btn-danger btn-xs edit"><i
                                        class="fa fa-times"></i><span data-culture="delete">删除</span></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var articleListObj = {
        grid: {
            keys: ['articleName'],
            url: "/cms/article/query/page",
            placeholder: '内容名称',
            stableparm: function () {
                return {};
            },
            events: {
                editArticle: function (row) {
                    pageParm.form = row;
                    loadpage("/views/cms/edit.html", true);
                },
                preview: function (row) {
                    window.open("views/cms/info/" + row.id + ".html");
                },
                deleteArticle: function (row) {
                    bootbox.confirm('确认删除？', function () {
                        deleteRowList([id = row.id]);
                    });
                }

            },
            tools: [{
                text: '新增', 'data-culture': 'add', img: 'fa fa-plus', event: function (selectItems) {
                    loadpage("/views/cms/edit.html", true);
                }
            }, {
                text: '编辑', 'data-culture': 'edit', img: 'fa fa-edit', event: function (selectItems) {
                    if (selectItems && selectItems.length == 1) {
                        pageParm.form = selectItems[0];
                        loadpage("/views/cms/edit.html", true);
                    }
                    else {
                        bootbox.alert('请选择一条记录！');
                    }
                }
            }, {
                text: '删除', 'data-culture': 'delete', img: 'fa fa-times', event: function (selectItems) {
                    if (selectItems && selectItems.length > 0) {
                        bootbox.confirm('确认删除？', function () {
                            var ids = [];
                            $.each(selectItems, function (i, row) {
                                ids.push(row.id);
                            });
                            deleteRowList(ids);
                        });
                    } else {
                        bootbox.alert('请选择待删除的记录！');
                    }
                }
            }]
        }
    };
    function deleteRowList(ids) {
        $.request('/cms/article/delete/ids', {ids: ids}, function () {
            bootbox.alert("删除成功!");
            articleListObj.grid.ext.refresh();
        }, function () {
            bootbox.alert("删除失败!");
        })
    }
    function init() {
        $("#grid-data").table(articleListObj.grid);
    }
    function dispose() {
        articleListObj = {};
    }
</script>
</body>
</html>